using UnityEngine;


namespace Brick
{
	public class Paddle : MonoBehaviour
	{
		public bool autoPlay;

		private Ball ball;

		private void Start()
		{
			ball = UnityEngine.Object.FindObjectOfType<Ball>();
		}

		private void Update()
		{
			if (!autoPlay)
			{
				MoveWithMouse();
			}
			else
			{
				AutoMove();
			}
		}

		private void MoveWithMouse()
		{
			Vector3 position = base.transform.position;
			Vector3 position2 = new Vector3(0.5f, position.y, 0f);
			Vector3 mousePosition = UnityEngine.Input.mousePosition;
			float value = mousePosition.x / (float)Screen.width * 16f;
			position2.x = Mathf.Clamp(value, 1.05f, 15f);
			base.transform.position = position2;
		}

		private void AutoMove()
		{
			Vector3 position = base.transform.position;
			Vector3 position2 = new Vector3(0.5f, position.y, 0f);
			Vector2 vector = ball.transform.position;
			position2.x = Mathf.Clamp(vector.x, 1f, 15f);
			base.transform.position = position2;
		}
	}
}

